<template>
  <basic-container>
    <avue-crud
      :option="option"
      :data="data"
      :table-loading="loading"
      @search-change="searchChange"
      @search-reset="searchReset"
      :page.sync="page"
      @size-change="sizeChange"
      @current-change="currentChange"
      @refresh-change="refreshChange"
      @on-load="onLoad"
    >
      <template slot="menuLeft">
        <el-button type="primary" @click="openAdd">新增</el-button>
      </template>
      <template slot="status" slot-scope="scope">
        <el-tag :type="['info', 'warning', 'danger', 'success', 'info'][scope.row.status]" effect="plain">
          {{ ['草稿', '审批中', '审批拒绝', '审批通过', '已作废'][scope.row.status] }}
        </el-tag>
      </template>
    </avue-crud>
  </basic-container>
</template>

<script>
import { option, page } from '@/option/tenant/supplier/eliminate'
export default {
  name: 'Relation',
  data() {
    return {
      loading: false,
      query: {},
      data: [
        {status:'0'},
        {status:'1'},
        {status:'2'},
        {status:'3'},
        {status:'4'},
      ],
      page,
      option: { ...option, operatingButtons: this.getOperatingButtons }
    }
  },
  methods: {
    getOperatingButtons(row) {
      const edit = { text: '编辑', callback: this.openEdit }
      const view = { text: '详情', callback: this.openView }
      const drop = { text: '删除', callback: this.handleDelete }
      if (row.row.status === '0') {
        return [edit, view, drop]
      } else if (row.row.status === '2') {
        return [edit, view]
      } else {
        return [view]
      }
    },
    openAdd() {
      this.$quickDrawer({
        title: '新增',
        width: '90%',
        component: require('@/views/tenant/supplier/eliminate/form').default,
        props: { type: 'add' },
        on: {
          refresh: () => {
            // this.onLoad(this.page)
          }
        },
        buttons: [
          { text: '保存', callback: 'handleSave' },
          { text: '提交', callback: 'handleSubmit' }
        ]
      })
    }
  }
}
</script>

<style></style>
